package com.edu.app.service.impl.core;

import com.edu.app.bean.core.SysActivity;
import com.edu.app.bean.core.SysCustomer;
import com.edu.app.bean.core.SysListOfValue;
import com.edu.app.bean.core.SysUser;
import com.edu.app.mapper.core.SysActivityMapper;
import com.edu.app.mapper.core.SysListOfValueMapper;
import com.edu.app.mapper.linkmappers.SysCustomerActivityMapper;
import com.edu.app.mapper.linkmappers.SysUserActivityMapper;
import com.edu.app.model.ActivityModel;

import com.edu.app.service.impl.SysBaseServiceImpl;
import com.edu.app.service.sys.core.SysActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysActivityServiceImpl extends SysBaseServiceImpl<SysActivity, SysActivityMapper> implements SysActivityService {
    @Autowired
    SysActivityMapper sysActivityMapper;

    @Autowired
    SysUserActivityMapper sysUserActivityMapper;

    @Autowired
    SysCustomerActivityMapper sysCustomerActivityMapper;

    @Autowired
    SysListOfValueMapper sysListOfValueMapper;



    @Override
    public Integer deleteActivityByTypeId(Integer type_id){
        return sysActivityMapper.deleteActivityByTypeId(type_id);
    }


    @Override
    public ActivityModel getActivityModelById(Integer id){
        SysActivity sysActivity = sysActivityMapper.selectById(id);
        List<SysUser> sysUserList = sysUserActivityMapper.getUserByActivityId(id);
        List<SysCustomer> sysCustomerList = sysCustomerActivityMapper.getCustomerByActivityId(id);
        SysListOfValue type = sysListOfValueMapper.selectById(sysActivity.getType_id());

        return new ActivityModel(sysActivity, sysUserList, sysCustomerList, type);
    }
}
